#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
int main(int argc, char const *argv[]){
    
int pd = open("love.txt",O_RDONLY);
    if (pd == -1){
        printf("打开文件失败\n");
        return -1;
    }
    int pd2 = open("love1.txt",O_WRONLY|O_CREAT|O_APPEND,0664);

    if (pd2 == -1)
    {
        printf("打开文件失败\n");
        close(pd);
        return -1;
    }
    char buff[1024];
ssize_t love_len = 0;
    while((love_len = read(pd,buff,sizeof(buff)))>0){

        write(pd2,buff,love_len);
        write(STDOUT_FILENO,buff,love_len);
    }
    if(love_len == -1){
        printf("读取文件失败3\n");
        close(pd);
        close(pd2);
        return -1;
    }
     close(pd);
        close(pd2);
    
    
    return 0;
}
   

